package com.police.view;

import java.util.ArrayList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.CheckBox;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;

import com.police.R;
import com.police.activity.MainActivity;
import com.police.model.SearchRecordDetailsBean;
/**
 * 点击搜索记录时弹出Pop
 * @author Administrator
 *
 */
public class SearchRecordDetailsPop extends LinearLayout{

	
	MainActivity main;
	ListView recordDetailsList;
	public LinearLayout layout;
	LayoutInflater inflater;
	LayoutParams layoutParams;
	SearchRecordDetailsAdapter adapter;
	ArrayList<SearchRecordDetailsBean>recordDetails=new ArrayList<SearchRecordDetailsBean>();
	public SearchRecordDetailsPop(Context context) {
		super(context);
		main=(MainActivity)context;
		// TODO Auto-generated constructor stub
		initView();
	}

	private void initView(){
		inflater = LayoutInflater.from(main);
		layout = (LinearLayout) inflater.inflate(R.layout.search_record_detail_view, null);
		layoutParams = new LayoutParams(LayoutParams.FILL_PARENT,
				LayoutParams.WRAP_CONTENT);
		recordDetailsList = (ListView) layout.findViewById(R.id.record_details_list);
		this.addView(layout, layoutParams);
		adapter = new SearchRecordDetailsAdapter();
		if (adapter != null) {
			recordDetailsList.setAdapter(adapter);
		}
		
	}
		private class SearchRecordDetailsAdapter extends BaseAdapter {

			@Override
			public int getCount() {
				// TODO Auto-generated method stub
				return recordDetails.size();
			}

			@Override
			public Object getItem(int position) {
				// TODO Auto-generated method stub
				return position;
			}

			@Override
			public long getItemId(int position) {
				// TODO Auto-generated method stub
				return position;
			}

			@Override
			public View getView(int position, View convertView, ViewGroup parent) {
				// TODO Auto-generated method stub
				SearchRecordDetailsBean bean = null;
				bean = recordDetails.get(position);
				if (bean == null) {
					return null;
				}
				ViewHolder holder;
				if (convertView == null) {
					convertView = inflater.inflate(R.layout.search_record_details_item, null);
					holder = new ViewHolder();
					holder.owner = (TextView) convertView
							.findViewById(R.id.owner);
					holder.phone = (TextView) convertView
							.findViewById(R.id.phone);
					holder.name = (TextView) convertView
							.findViewById(R.id.name);
					holder.time = (TextView) convertView
							.findViewById(R.id.time);
					holder.lac = (TextView) convertView
							.findViewById(R.id.lac);
					holder.cid = (TextView) convertView
							.findViewById(R.id.cid);
					holder.isMark = (CheckBox) convertView
							.findViewById(R.id.isMark);
					convertView.setTag(holder);
				}
				holder = (ViewHolder) convertView.getTag();
				holder.owner.setText(bean.owner);
				holder.phone.setText(bean.phone);
				holder.name.setText(bean.name);
				holder.time.setText(bean.time);
				holder.lac.setText(bean.lac);
				holder.cid.setText(bean.cid);
				return convertView;
			}

		}

		static class ViewHolder {

			public TextView owner;
			public TextView phone;
			public TextView name;
			public TextView time;
			public TextView lac;
			public TextView cid;
			public CheckBox isMark;
			
		}
	}

